<?
if($action==""){
?>
		<center><b>ข้อมูลส่วนตัว</b></center>
		<form method=POST action="install.php">
		<table>
		<tr><td>Username</td><td><input type=text name=u size=20></td></tr>
		<tr><td>Password</td><td><input type=password name=p size=20></td></tr>
		</table>
		<center><b>ข้อมูล MySQL</b></center>
		<table>
		<tr><td>Host</td><td><input type=text name=h size=20></td></tr>
		<tr><td>Username</td><td><input type=text name=u2 size=20></td></tr>
		<tr><td>Password</td><td><input type=password name=p2 size=20></td></tr>
		<tr><td>Database Name</td><td><input type=text name=datab size=20></td></tr>
		</table>
		<table>
		<tr><td>URL</td><td><input type=text name=ur size=28></td></tr>
		</table>
		<input type=hidden name=action value=change>
		<input type=submit value="&gt;&gt; Change &lt;&lt;">	<input type=reset value=Reset>
<?
		}elseif($action=="change"){
	@mysql_connect($h,$u2,$p2);
	$sql1="CREATE TABLE board_data (No int(255) NOT NULL auto_increment,Subject varchar(255) NOT NULL default '',Name varchar(255) NOT NULL default '',Email varchar(255) NOT NULL default '',Note longtext NOT NULL,Day datetime NOT NULL default '2000-00-00 00:00:00',Category varchar(255) NOT NULL default '',Reply varchar(255) NOT NULL default '',  PRIMARY KEY  (No))";
	$sql2="CREATE TABLE board_ans (No int(255) NOT NULL auto_increment,QNo varchar(255) NOT NULL default '',Note longtext NOT NULL,Name varchar(255) NOT NULL default '',Email varchar(255) NOT NULL default '',Day datetime NOT NULL default '2000-00-00 00:00:00',Category varchar(255) NOT NULL default '',PRIMARY KEY  (No))";
	$re1=mysql_db_query($datab,$sql1);
	$re2=mysql_db_query($datab,$sql2);
	if(($re1==0)&&($re2==0)) exit("Error");
			$file=fopen("config.inc.php","w");
			fputs($file,"<?\n");
			fputs($file,"\$host=\"$h\";\n");
			fputs($file,"\$user=\"$u2\";\n");
			fputs($file,"\$pwd=\"$p2\";\n");
			fputs($file,"\$dbname=\"$datab\";\n\n");
			fputs($file,"\$url=\"$ur\";\n\n");
			fputs($file,"\$admin_user=\"$u\";\n");
			fputs($file,"\$admin_pwd=\"$p\";\n");
			fputs($file,"?>");
			fclose($file);
			echo "Okay<br>\n";
			echo "เรียกไฟล์ดังนี้ครับ => webboard.php?Category=หมวด ครับ<br>\n";
			echo "[<a href='webboard.php?Category=$Category'>Home</a>]<br>\n";
		}
?>